package context

import (
	"net/http"
)

type Response struct {
	http.ResponseWriter
}

func (r *Response) reset(w http.ResponseWriter) {
	r.ResponseWriter = w
}

type Context struct {
	Request        *http.Request
	ResponseWriter *Response
}

func NewContext() *Context {
	return &Context{}
}

//初始化
func (this *Context) Reset(w http.ResponseWriter, r *http.Request) {
	this.Request = r
	if this.ResponseWriter == nil {
		this.ResponseWriter = &Response{}
	}
	this.ResponseWriter.reset(w)
}

//打印字符到屏幕
func (this *Context) WriteString(content string) {
	this.ResponseWriter.Write([]byte(content))
}
